//package com.example.demo.config.loginConfig;
//
//import com.auth0.jwt.interfaces.DecodedJWT;
//import com.example.demo.commom.JwtUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.redis.core.StringRedisTemplate;
//import org.springframework.stereotype.Component;
//import org.springframework.web.servlet.HandlerInterceptor;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
//@Component
//public class LoginInterceptor implements HandlerInterceptor {
//
//    @Autowired
//    private StringRedisTemplate redisTemplate;
//
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        //用户登录业务判断
//        //获取token及id
//        String token = request.getHeader("token");
//        if(!JwtUtils.checkToken(token)){
//            return false;
//        }
//        DecodedJWT decodedJWT = JwtUtils.getTokenInfo(token);
//        int id = decodedJWT.getClaim("id").asInt();
//        String token1 = redisTemplate.opsForValue().get("USER_LOGIN_" + id);
//        if(token1 == null){
//            return false;
//        }
//        return true;
//    }
//}